<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD><TITLE>Safe manual page - Tk Tk Built-In Commands</TITLE>
<link rel="stylesheet" href="../docs.css" type="text/css" media="all">
</HEAD>
<BODY><H2><a href="../contents.htm">Tcl8.6.11/Tk8.6.11 Documentation</a> <small>&gt;</small> <a href="contents.htm">Tk Commands</a> <small>&gt;</small> loadTk</H2>
<H3><A HREF="../UserCmd/contents.htm">Tcl/Tk Applications</A> | <A HREF="../TclCmd/contents.htm">Tcl Commands</A> | <A HREF="../TkCmd/contents.htm">Tk Commands</A> | <A HREF="../ItclCmd/contents.htm">[incr Tcl] Package Commands</A> | <A HREF="../SqliteCmd/contents.htm">SQLite3 Package Commands</A> | <A HREF="../TdbcCmd/contents.htm">TDBC Package Commands</A> | <A HREF="../TdbcmysqlCmd/contents.htm">tdbc::mysql Package Commands</A> | <A HREF="../TdbcodbcCmd/contents.htm">tdbc::odbc Package Commands</A> | <A HREF="../TdbcpostgresCmd/contents.htm">tdbc::postgres Package Commands</A> | <A HREF="../TdbcsqliteCmd/contents.htm">tdbc::sqlite3 Package Commands</A> | <A HREF="../ThreadCmd/contents.htm">Thread Package Commands</A> | <A HREF="../TclLib/contents.htm">Tcl C API</A> | <A HREF="../TkLib/contents.htm">Tk C API</A> | <A HREF="../ItclLib/contents.htm">[incr Tcl] Package C API</A> | <A HREF="../TdbcLib/contents.htm">TDBC Package C API</A></H3>
<H3><A NAME="M2">NAME</A></H3>
safe::loadTk &mdash; Load Tk into a safe interpreter.
<H3><A NAME="M3">SYNOPSIS</A></H3>
<B>safe::loadTk </B><I>child</I> ?<B>-use</B> <I>windowId</I>? ?<B>-display</B> <I>displayName</I>?<BR>
<H3><A NAME="M4">DESCRIPTION</A></H3>
Safe Tk is based on Safe Tcl, which provides a mechanism that allows
restricted and mediated access to auto-loading and packages for safe
interpreters.  Safe Tk adds the ability to configure the interpreter for safe
Tk operations and load Tk into safe interpreters.
<P>
The <B>safe::loadTk</B> command initializes the required data structures in
the named safe interpreter and then loads Tk into it.  The interpreter must
have been created with <B>safe::interpCreate</B> or have been initialized
with <B>safe::interpInit</B>.  The command returns the name of the safe
interpreter.  If <B>-use</B> is specified, the window identified by the
specified system dependent identifier <I>windowId</I> is used to contain the
&ldquo;.&rdquo;
window of the safe interpreter; it can be any valid id, eventually referencing
a window belonging to another application. As a convenience, if the window you
plan to use is a Tk Window of the application you can use the window name
(e.g.,
&ldquo;<B>.x.y</B>&rdquo;)
instead of its window Id (e.g., from <B><A HREF="../TkCmd/winfo.htm">winfo id</A></B> <B>.x.y</B>).
When <B>-use</B> is not specified, a new toplevel window is created for the
&ldquo;.&rdquo;
window of the safe interpreter. On X11 if you want the embedded window to use
another display than the default one, specify it with <B>-display</B>.  See
the <B><A HREF="#M5">SECURITY ISSUES</A></B> section below for implementation details.
<H3><A NAME="M5">SECURITY ISSUES</A></H3>
Please read the <B><A HREF="../TclCmd/safe.htm">safe</A></B> manual page for Tcl to learn about the basic
security considerations for Safe Tcl.
<P>
<B>safe::loadTk</B> adds the value of <B><A HREF="../TkCmd/tkvars.htm">tk_library</A></B> taken from the parent
interpreter to the virtual access path of the safe interpreter so that
auto-loading will work in the safe interpreter.
<P>
Tk initialization is now safe with respect to not trusting the child's state
for startup. <B>safe::loadTk</B> registers the child's name so when the Tk
initialization (<B><A HREF="../TkLib/Tk_Init.htm">Tk_SafeInit</A></B>) is called and in turn calls the parent's
<B>safe::InitTk</B> it will return the desired <B><A HREF="../TclCmd/tclvars.htm">argv</A></B> equivalent
(<B>-use</B> <I>windowId</I>, correct <B>-display</B>, etc.)
<P>
When <B>-use</B> is not used, the new toplevel created is specially decorated
so the user is always aware that the user interface presented comes from a
potentially unsafe code and can easily delete the corresponding interpreter.
<P>
On X11, conflicting <B>-use</B> and <B>-display</B> are likely to generate a
fatal X error.
<H3><A NAME="M6">SEE ALSO</A></H3>
<B><A HREF="../TclCmd/safe.htm">safe</A></B>, <B><A HREF="../TclCmd/interp.htm">interp</A></B>, <B><A HREF="../TclCmd/library.htm">library</A></B>, <B><A HREF="../TclCmd/load.htm">load</A></B>, <B><A HREF="../TclCmd/package.htm">package</A></B>, <B><A HREF="../TclCmd/source.htm">source</A></B>, <B><A HREF="../TclCmd/unknown.htm">unknown</A></B>
<H3><A NAME="M7">KEYWORDS</A></H3>
<A href="../Keywords/A.htm#alias">alias</A>, <A href="../Keywords/A.htm#auto-loading">auto-loading</A>, <A href="../Keywords/A.htm#auto_mkindex">auto_mkindex</A>, <A href="../Keywords/L.htm#load">load</A>, <A href="../Keywords/P.htm#parent interpreter">parent interpreter</A>, <A href="../Keywords/S.htm#safe
interpreter">safe
interpreter</A>, <A href="../Keywords/C.htm#child interpreter">child interpreter</A>, <A href="../Keywords/S.htm#source">source</A>
<div class="copy">Copyright &copy; 1995-1996 Sun Microsystems, Inc.
</div>
</BODY></HTML>
